package com.zhongyouyun.admin.controller;


import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.lang.tree.Tree;
import com.zhongyouyun.admin.model.DeptModel;
import com.zhongyouyun.admin.pojo.AnalysisPojo;
import com.zhongyouyun.admin.service.AnalysisService;
import com.zhongyouyun.other.model.Result;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import lombok.NonNull;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;

/**
 * @Author: shenyi
 * @Date: 2021-12-17
 * @Description:
 */
@RestController
@RequestMapping("/admin/z_analysis")
@Api(value = "统计分析controller", tags = {"统计分析接口"})
public class AnalysisController {
    @Autowired
    private AnalysisService service;
//    @PostMapping("/findUserStateAnalysis")
//    @ResponseBody
//    @ApiOperation(value = "获取用户状态统计", notes = "获取用户状态统计列表")
//    public Result findUserStateAnalysis(){
//        List<AnalysisPojo> list= service.findUserStateAnalysis();
//        if(list.size()>0){
//            Map<String, Object> resultMap = new LinkedHashMap<String, Object>();
//            resultMap.put("list",list);
//            return   Result.builder().message("成功").status(0).data(resultMap).build();
//        }else{
//            return   Result.builder().message("没有任何权限").status(1).build();
//        }
//    }
//    @PostMapping("/findHomeCensus")
//    @ResponseBody
//    @ApiOperation(value = "获取首页统计", notes = "获取首页统计列表")
//    public Result findHomeCensus(){
//        Map<String, Object> resultMap = new LinkedHashMap<String, Object>();
//        resultMap= service.findHomeCensus();
//        if(resultMap.size()>0){
//            return   Result.builder().message("成功").status(0).data(resultMap).build();
//        }else{
//            return   Result.builder().message("没有任何权限").status(1).build();
//        }
//    }

    @PostMapping("/findUserStateAnalysisbyDept")
    @ResponseBody
    @ApiOperation(value = "获取首页统计", notes = "获取首页统计列表")
    public Result findUserStateAnalysisbyDept(@NonNull @ApiParam(value = "deptId") @RequestParam(value = "deptId", required = false) int deptId, @NonNull @ApiParam(value = "state") @RequestParam(value = "state", required = false) int state) {

        List<Map<String, Integer>> list = service.findUserStateAnalysisbyDept(deptId, state);
        if (list.size() > 0) {
            return Result.builder().message("成功").status(0).data(list).build();
        } else {
            return Result.builder().message("没有任何权限").status(1).build();
        }
    }
}
